package com.moss.cloud.base.biz.controller;

import com.moss.cloud.base.api.model.from.BaseFrom;
import com.moss.cloud.base.api.model.from.BatchBaseFrom;
import com.moss.cloud.base.biz.service.ISysRoleMenuService;
import com.moss.cloud.common.core.constant.ServiceList;
import com.moss.cloud.common.core.model.Result;
import com.moss.cloud.common.security.annotation.SysLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 角色菜单前端控制器
 *
 * @author 瑾年
 * @date 2023年11月9日
 */
@RestController
@RequestMapping(ServiceList.BASE + "/sysRoleMenu")
public class SysRoleMenuController {
    private ISysRoleMenuService sysRoleMenuService;

    public SysRoleMenuController(ISysRoleMenuService sysRoleMenuService) {
        this.sysRoleMenuService = sysRoleMenuService;
    }

    /**
     * 查询角色的菜单集合
     *
     * @param
     * @return
     */
    @PostMapping("/roleMenuIds")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "查询角色的菜单集合")
    public Result<?> roleMenuIds(@RequestBody @Validated BaseFrom baseFrom) {
        return Result.success(sysRoleMenuService.roleMenuIds(baseFrom.getId()));
    }

    /**
     * 角色批量授权菜单
     *
     * @param batchBaseFrom
     * @return
     */
    @PostMapping("/roleAuthMenus")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "角色批量授权菜单")
    public Result<?> roleAuthMenus(@RequestBody @Validated BatchBaseFrom batchBaseFrom) {
        return Result.success(sysRoleMenuService.roleAuthMenus(batchBaseFrom));
    }
}
